package com.cong._60;

import java.util.LinkedList;
import java.util.List;

class Solution {
    private char[] seq = new char[] {'1', '2', '3', '4', '5', '6'};
    private List<String> res = new LinkedList<>();

    public void getPermutation(int startIndex) {
        if (startIndex == seq.length - 1) {
            res.add(String.copyValueOf(seq));
            return;
        }
        for (int i = startIndex;i < seq.length;i++) {
            char tmp = seq[startIndex];
            seq[startIndex] = seq[i];
            seq[i] = tmp;
            getPermutation(startIndex + 1);
            tmp = seq[startIndex];
            seq[startIndex] = seq[i];
            seq[i] = tmp;
        }
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        s.getPermutation(0);
        s.res.forEach(System.out::println);

    }
}